import 'package:flutter/material.dart';

import 'generated/assets.dart';

class imageStudy extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(child: Column(
      children: [
        _buildCircleImageWithBorder() ,
        _buildImage(),
        _buildCircleImage(),
        _buildCircleImageWithClipOval(),
        FadeInImage.assetNetwork(placeholder: Assets.assetsImagesPic2,
            image: 'https://img1.baidu.com/it/u=2172818577,3783888802&fm=253&app=138&f=JPEG?w=800&h=1422',
          fit: BoxFit.cover,
          width: 100,
          height: 100,)

      ],
    ));
  }

  Widget _buildImage() {
    return Container(
      child: Image.network(

        'https://img1.baidu.com/it/u=2172818577,3783888802&fm=253&app=138&f=JPEG?w=800&h=1422',
        filterQuality: FilterQuality.high,
        fit: BoxFit.cover,
        // center crop
        repeat: ImageRepeat.repeatX,
        width: 100,
        height: 100,

      ),
      width: 200,
      height: 200,
      /* 这里的装饰器就相当于设置背景一样 圆型图片的设置*/
      decoration: BoxDecoration(
        color: Colors.yellow,
        borderRadius: BorderRadius.all(Radius.circular(100)),
      ),
    );
  }

  /*圆形图片 通过 border*/
  Widget _buildCircleImageWithBorder() {
    return Container(
      width: 200,
      height: 200,
      /* 这里的装饰器就相当于设置背景一样 圆型图片的设置*/
      decoration: BoxDecoration(
        color: Colors.yellow,
        // border: Border.all(color: Colors.red, width: 10),
        image: DecorationImage(
          image: NetworkImage(
            'https://img1.baidu.com/it/u=2172818577,3783888802&fm=253&app=138&f=JPEG?w=800&h=1422',
          ),
          fit: BoxFit.cover,
        ),
        borderRadius: BorderRadius.all(Radius.circular(100)),
      ),
    );
  }

  /* 圆形图片*/
  Widget _buildCircleImage() {
    return Container(
      child: CircleAvatar(
        backgroundImage: NetworkImage(
          'https://img1.baidu.com/it/u=2172818577,3783888802&fm=253&app=138&f=JPEG?w=800&h=1422',
        ),
        radius: 50,
        child: Container(decoration: BoxDecoration(shape: BoxShape.circle)),
      ),
    );
  }

  Widget _buildCircleImageWithClipOval() {
    return Container(
      child: ClipOval(

        child: Image.network(
          'https://img1.baidu.com/it/u=2172818577,3783888802&fm=253&app=138&f=JPEG?w=800&h=1422',
          filterQuality: FilterQuality.high,
          fit: BoxFit.cover,
          // center crop
          repeat: ImageRepeat.repeatX,
          width: 100,
          height: 100,
        )
      ),
    );
  }
}
